from constants.constants import ChargeMode,RestartType,IsErrorType
from model.charge import ChargeStart, ChargeStop
from model.device_log import OnlineLogReq
from model.device_state import DeviceStateReq,DeviceStateRestart,DeviceStateOffline,DeviceStateOfflineProfit,DeviceStatePortError
from model.renew import CreateCompanyRenewOrderReq,GetCompanyExpireDeviceListReq,GetCompanyRenewStatusReq
from model.info import GetDeviceSettingOnlineCardInfoReq,DeviceSaveModeReq,GetDeviceModeTimeInfoReq,GetDeviceModeTime1InfoReq
from model.common import PageModel
from sdk.device_log import DeviceLog
from sdk.device_state import DeviceState
from sdk.renew import Renew
from sdk.client import Client
from sdk.charge import Charge
from sdk.info import Info

def main():
    app_id = "请联系万桩工作人员获取"
    app_secret = "请联系万桩工作人员获取"
    base_url = "请联系万桩工作人员获取"
    device_num = "请联系万桩工作人员获取"
    trade_no = "请联系万桩工作人员获取"
    device_nums = [device_num]
    charge_mode = ChargeMode.ChargeModeEnergyMode

    client = Client(app_id, app_secret, base_url)


    infoClient = Info(client)
    res = infoClient.get_device_setting_online_card_info(GetDeviceSettingOnlineCardInfoReq(device_num))
    print("get_device_setting_online_card_info   =====> ", res)

    res = infoClient.get_device_mode_time_info(GetDeviceModeTimeInfoReq(device_num))
    print("get_device_mode_time_info   =====> ", res)

    res = infoClient.get_device_mode_time1_info(GetDeviceModeTime1InfoReq(device_num))
    print("get_device_mode_time1_info   =====> ", res)

    res = infoClient.get_device_setting_coin_info(GetDeviceSettingOnlineCardInfoReq(device_num))
    print("get_device_setting_coin_info   =====> ", res)

    res = infoClient.device_save_mode(DeviceSaveModeReq(device_num=device_num,charge_mode=charge_mode,max_power=100,start_fee=0,max_pay_fee=100,payment_value=[10,20],time_value=[10,20],work_charge=1,work_charge_fourdigit=10,power_value=[20,30],price_value=[40,50],check_time=10,inc_time=10,type=1,count_mode=1,display_delay="",is_not_disturb="",not_disturb_start="",not_disturb_end="",not_disturb_volume=10))
    print("device_save_mode   =====> ", res)

    # ...


    charge = Charge(client)  
    res = charge.charge_start(ChargeStart(device_num, "1", 10033, charge_mode, 100))
    print("charge_start   =====> ", res)

    res = charge.charge_stop(ChargeStop(device_num, "1", 10033))
    print("charge_stop   =====> ", res)



    deviceLog = DeviceLog(client)  
    res = deviceLog.online_log(OnlineLogReq(device_num,PageModel(page=1,limit=10)))
    print("online_log   =====> ", res)



    renewClient = Renew(client)
    res = renewClient.create_company_renew_order(CreateCompanyRenewOrderReq(device_nums,trade_no))
    print("create_company_renew_order   =====> ", res)

    res = renewClient.get_company_expire_device_list(GetCompanyExpireDeviceListReq (PageModel(page=1,limit=10)))
    print("get_company_expire_device_list   =====> ", res)

    res = renewClient.get_company_renew_status(GetCompanyRenewStatusReq (trade_no))
    print("get_company_renew_status   =====> ", res)
    


    deviceState = DeviceState(client)  
    rtp = RestartType.RestartTypeModule
    res = deviceState.device_state_restart(DeviceStateRestart(device_nums,rtp))
    print("device_state_restart   =====> ", res)

    res = deviceState.device_state_offline(DeviceStateOffline(device_nums))
    print("device_state_offline   =====> ", res)

    res = deviceState.device_state_offline_profit(DeviceStateOfflineProfit(device_nums,"0","0"))
    print("device_state_offline_profit   =====> ", res)

    iserrType = IsErrorType.IsErrorTypeOK
    res = deviceState.device_state_port_error(DeviceStatePortError(device_nums,0,iserrType))
    print("device_state_port_error   =====> ", res)

    res = deviceState.device_state(DeviceStateReq(device_num,["state","eq_used"]))
    print("device_state   =====> ", res)


if __name__ == "__main__":
    main()